package sch.frog.creational.builderpattern.builder;

import sch.frog.creational.builderpattern.product.B.BPartOne;
import sch.frog.creational.builderpattern.product.B.BPartTwo;
import sch.frog.creational.builderpattern.product.B.BProduct;
import sch.frog.creational.builderpattern.product.IProduct;

public class BProductBuilder implements Builder {

    private BPartOne partOne;

    private BPartTwo partTwo;

    @Override
    public void buildPartOne() {
        this.partOne = new BPartOne();
    }

    @Override
    public void buildPartTwo() {
        this.partTwo = new BPartTwo(this.partOne);
    }

    private String name;

    private int value;

    public Builder setName(String name){
        this.name = name;
        return this;
    }

    public Builder setValue(int value){
        this.value = value;
        return this;
    }

    @Override
    public IProduct build() {
        BProduct product = new BProduct();
        product.setbPartTwo(this.partTwo);
        product.setName(this.name);
        product.setValue(this.value);
        return product;
    }
}
